<script setup lang="ts">
// import { ref } from 'vue'
import { useRouter } from 'vue-router'

const router = useRouter()
const { path } = router.currentRoute.value

const activeIndex = path

const toUserPage = () => {
  router.push({
    name: 'user'
  })
}
</script>

<template>
  <div class="common-layout">
    <el-container>
      <el-header class="header">
        <div class="title">
          <img src="~@/assets/images/logo.png" alt="" class="title-logo">
          <span class="title-text">管理系统
            <el-divider class="divider" direction="vertical" />
          </span>
        </div>
        <el-menu
          :default-active="activeIndex"
          class="el-menu-demo"
          mode="horizontal"
          router
        >
          <el-menu-item index="/manage/daily/customerManage">每日配送</el-menu-item>
          <el-menu-item index="/manage/message/customerMessage">信息管理</el-menu-item>
        </el-menu>
        <div @click="toUserPage" class="user-info">
          <el-avatar :size="40" shape="square" src="https://cube.elemecdn.com/9/c2/f0ee8a3c7c9638a54940382568c9dpng.png" />
          <div class="user-info-name">index</div>
        </div>
      </el-header>
      <el-container class="container">
        <router-view/>
      </el-container>
    </el-container>
  </div>
</template>

<style lang="scss" scoped>
.common-layout {
  margin: 0;
  padding: 0;
}
.header {
  padding: 0;
  display: flex;
  flex-wrap: nowrap;
  background-color: #fff;
  .title {
    width: 200px;
    display: flex;
    flex-wrap: nowrap;
    border-bottom: solid 1px #dcdfe6;
    // border-right: solid 1px #dcdfe6;
    &-logo {
      height: 59px;
    }
    &-text {
      margin-left: 20px;
      line-height: 59px;
      font-size: 18px;
      font-weight: bold;
    }
  }
  .el-menu-demo {
    flex: 1;
  }
  .user-info {
    border-bottom: solid 1px #dcdfe6;
    padding: 10px 0;
    width: 200px;
    &-name {
      display: inline-block;
      margin-left: 8px;
      font-size: 20px;
    }
  }

}
.container {
  margin-top: 10px;
  width: 100%;
}
</style>
